﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.DataAccess.Kernel
{
    /// <summary>
    /// 数据访问接口适配器工厂
    /// </summary>
    public class DatabaseFactory
    {
        public static IDatabase CreateDefaultDatabase()
        {
            return new DatabaseImpl();
        }

        public static IDatabase CreateDatabase(DatabaseType dbType)
        {
            switch (dbType)
            {
                case DatabaseType.ES:
                    return new ESDatabase();
                case DatabaseType.SQLServer:
                case DatabaseType.PostgreSQL:
                case DatabaseType.MySQL:
                case DatabaseType.Oracle:
                    return CreateDefaultDatabase();
                default:
                    return CreateDefaultDatabase();
            }
        }

        public static IDatabase CreateDatabase(string databaseType)
        {
            DatabaseType dbType = (DatabaseType)Enum.Parse(typeof(DatabaseType), databaseType);
            return CreateDatabase(dbType);
        }
    }
}
